function loginCheck(pageObj) {
  if (pageObj.onLoad) {
      let _onLoad = pageObj.onLoad;
      pageObj.onLoad = function (options) {
          if(wx.getStorageSync('userInfo')) {
              let currentInstance = getPageInstance();
              _onLoad.call(currentInstance, options);
          } else {
              wx.redirectTo({
                  url: "/pages/login/login"
              });
          }
      }
  }
  return pageObj;
}

// 获取当前页面    
function getPageInstance() {
  var pages = getCurrentPages();
  return pages[pages.length - 1];
}

exports.loginCheck = loginCheck;
